cmake_minimum_required(VERSION 3.0)

include_directories(${LOG4X_SRC_DIR} ${LOG4X_SRC_DIR}/os ${LOG4X_SRC_DIR}/echo)

set(CONFIGS log.ini)

if(NOT MSVC)
    link_libraries(-Wl,-rpath,./)
endif()

if(BUILD_SHARED_LIBS)
    add_executable(log4x_test main.cpp)
    target_link_libraries(log4x_test log4x)
    set_target_properties(log4x_test PROPERTIES
        OUTPUT_NAME                      "log4x_test"
        DEBUG_OUTPUT_NAME                "log4x_test${CMAKE_DEBUG_POSTFIX}")
    install(TARGETS log4x_test DESTINATION bin)

    add_executable(log4xecho_test echo.cpp)
    target_link_libraries(log4xecho_test log4x)
    set_target_properties(log4xecho_test PROPERTIES
        OUTPUT_NAME                      "log4xecho_test"
        DEBUG_OUTPUT_NAME                "log4xecho_test${CMAKE_DEBUG_POSTFIX}"
        )
    install(TARGETS log4xecho_test DESTINATION bin)
endif()

if(BUILD_STATIC_LIBS)
    add_definitions(-DLOG4X_STATICLIB)
    if (MINGW)
        set(CMAKE_EXE_LINKER_FLAGS "-static")
    endif()

    add_executable(log4x_test_static main.cpp)
    target_link_libraries(log4x_test_static log4x_static)
    set_target_properties(log4x_test_static PROPERTIES
        OUTPUT_NAME                      "log4x_test_static"
        DEBUG_OUTPUT_NAME                "log4x_test_static${CMAKE_DEBUG_POSTFIX}")
    install(TARGETS log4x_test_static DESTINATION bin)

    add_executable(log4xecho_test_static echo.cpp)
    target_link_libraries(log4xecho_test_static log4x_static)
    set_target_properties(log4xecho_test_static PROPERTIES
        OUTPUT_NAME                      "log4xecho_test_static"
        DEBUG_OUTPUT_NAME                "log4xecho_test_static${CMAKE_DEBUG_POSTFIX}")
    install(TARGETS log4xecho_test_static DESTINATION bin)
endif()

install(FILES ${CONFIGS} DESTINATION bin)
